#pragma once
#include <iostream>
using namespace std;

class task
{
public:
    task(int num1, int num2, char symbol)
        : _num1(num1), _num2(num2), _symbol(symbol)
    {
    }

    int dotask()
    {
        int sum = 0;
        switch (_symbol)
        {
        case '+':
            sum = _num1 + _num2;
            break;
        case '-':
            sum = _num1 - _num2;
            break;
        case '*':
            sum = _num1 * _num2;
            break;
        case '/':
        {
            if (_num2 == 0)
            {
                cout << "除零错误" << endl;
                break;
            }
            sum = _num1 / _num2;
            break;
        }
        case '%':
        {
            if (_num2 == 0)
            {
                cout << "除零错误" << endl;
                break;
            }
            sum = _num1 % _num2;
            break;
        }
        default:
            cout << "非法错误" << endl;
        }
        return sum;
    }
    void get(int* num1,int* num2,char* symbol)
    {
        *num1 = _num1;
        *num2 = _num2;
        *symbol = _symbol;
    }
private:
    int _num1;
    int _num2;
    char _symbol;
};